package com.zyx.xunyilu.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.zyx.xunyilu.entity.Ctos;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * @ClassName: CtosMapper
 * @author: zyx
 * @E-mail: 1377631190@qq.com
 * @DATE: 2019/11/14 20:31
 */
public interface CtosMapper extends BaseMapper<Ctos> {

    /**
     *
     * @param symptoms
     * @return
     */
    @Select("<script> SELECT  conditions.content FROM ctos INNER JOIN conditions ON ctos.b_id = conditions.id " +
            "INNER JOIN symptom ON ctos.z_id = symptom.id " +
            "WHERE symptom.`name` in " +
            "<foreach item='symptom' index='index' collection='symptoms' open='(' separator=',' close=')'> " +
            " #{symptom} " +
            "</foreach> " +
            "GROUP BY conditions.content HAVING Count( conditions.content ) > ${symptoms.size - 1} " +
            "</script>")
    IPage<String> getList(Page<String> param, @Param("symptoms") List<String> symptoms);

}
